package com.stefanini.pe.bbva.mbl.in.dao;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.stefanini.pe.bbva.mbl.carga.in.to.LogAccion;
import com.stefanini.pe.bbva.mbl.carga.in.to.LogAccionKey;
import com.stefanini.pe.bbva.mbl.in.dao.iface.LogAccionDAO;
import com.stefanini.pe.bbva.mbl.in.utils.Util;

import org.apache.log4j.Logger;


public class LogAccionDAOImpl extends SqlMapClientDaoSupport implements LogAccionDAO {
	private static Logger logger = Logger.getLogger(LogAccionDAOImpl.class);
	
    public LogAccionDAOImpl() {
        super();
    }

    public int deleteByPrimaryKey(LogAccionKey key) {
    	int rows = 0;
    	
    	logger.info("Inicio");
        
    	rows = getSqlMapClientTemplate().delete("LOG_ACCION.ibatorgenerated_deleteByPrimaryKey", key);
    	
    	logger.info("Fin");
    	
        return rows;
    }

    public void insert(LogAccion record) {
    	logger.info("Inicio");
    	
        getSqlMapClientTemplate().insert("LOG_ACCION.ibatorgenerated_insert", record);
        
        logger.info("Fin");
    }

    public void insertSelective(LogAccion record) {
    	logger.info("Inicio");
    	
        getSqlMapClientTemplate().insert("LOG_ACCION.ibatorgenerated_insertSelective", record);
        
        logger.info("Fin");
    }

    public LogAccion selectByPrimaryKey(LogAccionKey key) {
    	LogAccion record = null;
    	
    	logger.info("Inicio");
    	
        record = (LogAccion) getSqlMapClientTemplate().queryForObject("LOG_ACCION.ibatorgenerated_selectByPrimaryKey", key);
        
        logger.info("Fin");
        
        return record;
    }

    public int updateByPrimaryKeySelective(LogAccion record) {
    	int rows = 0;
    	
    	logger.info("Inicio");
    	
        rows = getSqlMapClientTemplate().update("LOG_ACCION.ibatorgenerated_updateByPrimaryKeySelective", record);
        
        logger.info("Fin");
        
        return rows;
    }

    public int updateByPrimaryKey(LogAccion record) {
    	int rows = 0;
    	
    	logger.info("Inicio");
    	
        rows = getSqlMapClientTemplate().update("LOG_ACCION.ibatorgenerated_updateByPrimaryKey", record);
        
        logger.info("Fin");
        
        return rows;
    }
    
	public List selectAll() {
		List records = null;
	    
		logger.info("Inicio");
		
		records = (List) getSqlMapClientTemplate().queryForList("LOG_ACCION.ibatorgenerated_selectAll",null);
		
		logger.info("Fin");
		
		return records;
	}

	
  public List selectByCriteria(LogAccion logAccion)  {
	  List lista_total = new ArrayList();
	  List records = null;
	  List records_count = null;
	  HashMap map = null;
	  
	  records = (List) getSqlMapClientTemplate().queryForList("LOG_ACCION.ibatorgenerated_selectByCriteria",logAccion);
      records_count = (List) getSqlMapClientTemplate().queryForList("LOG_ACCION.ibt_selectByCriteria_Count",logAccion);
      map = (HashMap)records_count.get(0);
      lista_total.add(records);
      lista_total.add(map.get("COUNT"));
      
      return lista_total;
	}
}